Contents Screen
TAdrockFormPosition

Properties      Methods      Events      Installation

Unit

SaveFrm

Registration

Registration of this control is available on-line via the CompuServe SWREG forum

Standard Registration 	$15.00 US.	Go SWREG #7689

Full Source Registration	$55.00 US.	Go SWREG #9044

Please contact us at  CompuServe 100353,110 or Internet: Adrock@USA.NET

Please set your subject line to TAdrockFormPosition for all correspondence regarding this component.

Include your name, EMAIL or physical address and Visa Number and Expiry Date if ordering directly.

Description

Use a TAdrockFormPosition component when you need to save the position and size of a form.  The component now saves the state of the window as well. This means that a Maximized window can be restored maximized. You can not save the state of a window that is minimized.

There is no limit to the number of the TAdrockFormPosition components used in a single project.

To use this control just drop on your form, set the name of an INI file to write the settings to and set the section name property. The section name property defines the name of the section that gets written to in the INI file.

Note:	One other thing you need to check is that the Position property of the form is set to poDefault, if the Position property is set to poScreenCenter then the form will always be opened in the Screen Center although the size will be the saved size.

Another Adrock Software component that goes well with this component is TAdrockSaveGrid which can save the position, size and visibility of fields in a DBGrid. This requires only setting the INI file name, and the section name, and two lines of code, one to load the saved settings and one to save the settings. The TAdrockSaveGrid can use the same INI file as this component. Registration of the TAdrockSaveGrid  component is available on-line via the CompuServe SWREG forum for $15.00 US. Go SWREG #7688


Properties

This is the properties page for TAdrockFormPosition, please select a property.

IniFile

Name

SectionName

SaveDefaultDetails

Tag

WriteWhenLoaded


Methods

ReadIniFileSettings	Read the form size, and position and set the form to those settings.

WriteIniFileSettings	Write the current size and position of the form now.

RestoreDefaultIniFileSettings	Restore the default form size, and position.

SaveDefaultIniFileSettings	Save the current size and position as the default details.


Events

There are no events for this component.


INIFile

Applies to

TAdrockFormPosition components

Declaration

property IniFile : String;

Description

Set this property to the name of the INI file that will be used to write the form position and size details in. The INI file will be created if it does not exist.


SectionName

Applies to

TAdrockFormPosition components

Declaration

property SectionName : String;

Description

Set this property to the name of the section that is used in the INI file to store the details of the form size and position.


WriteWhenLoaded

Applies to

TAdrockFormPosition components

Declaration

property WriteWhenLoaded : Boolean;

Description

When you use this component it will display the form at the position and size that was last saved, this is what it is designed to do. But if you change the size of the form in design mode and then run the form it will still show the old position and size. To get around this problem you can set this property to TRUE so that the size and position instead of being read will be written. You then should exit the program, and change this setting back to false.

Other than this you could modify the INI file settings manually, but this could be more trouble than it is worth.


WriteIniFileSettings

Applies to

TAdrockFormPosition components

Declaration

Procedure WriteIniFileSettings;

Description

You can call this method directly to write the current position and size of the form to the .ini file. This allows you to update the details when you want to.

You must set the name of the INI file and the name of the section before calling this method.

Example

procedure TSDIAppForm.FormDestroy(Sender: TObject);

begin

  AdrockFormPosition1.IniFile := 'c:\tmp1.Ini';

  AdrockFormPosition1.SectionName := 'John';

  AdrockFormPosition1.WriteIniFileSettings;

end;


ReadIniFileSettings

Applies to

TAdrockFormPosition components

Declaration

procedure ReadIniFileSettings;

Description

This method is used to read the .ini file settings and restore the size and position of the form at runtime.

By leaving the name of the .Ini file blank at design time you are able to control the restoration of the size and position of the form when you want to. You might want the .ini file to be written to the directory where the program resides and this can not be known in advance since a user might install your program anywhere.

Example

procedure TSDIAppForm.FormCreate(Sender: TObject);

begin

  Application.OnHint := ShowHint;

  AdrockFormPosition1.IniFile := 'c:\tmp1.Ini';

  AdrockFormPosition1.SectionName := 'John';

  AdrockFormPosition1.ReadIniFileSettings;

end;


TAdrockFormPosition

Applies to

TAdrockFormPosition components

Click here for the Contents Page


Installation Instructions

To install this component>

•	Getting Started
	•	UNZIP the archive (eg: ADSAVFRM.ZIP) to a directory temporally.
	•	Create a directory to hold this component and any others that you will install in the future. (eg: C:\DELPHI\COMPONEN) It is easier to put new components in a separate directory since you can update them easily and if there is a new release of DELPHI it will not effect your component directory.
•	Installation of the HLP and KWF files.
	•	Exit DELPHI is you are running it, as you can not install the KWF file while delphi is running.
	•	Move or copy help file (e.g.: SAVEFRM.HLP) to your Delphi Bin directory (suggest C:\DELPHI\BIN), it only really needs to be somewhere on the path, but the DELPHI bin directory is a good place.
	•	Delphi has a program to add our help index to Delphis help index. What this does is allow you to search for both delphi commands and the commands and properties of the component you want to install. This program is called HELPINST and is found in the DELPHI\HELP sub directory. Copy the keyword file (SAVEFRM.KWF) to the delphi help directory.
	•	Change the current directory to the Delphi Help directory (e.g.: CD C:\DELPHI\HELP)
	•	Run the HELPINST program and load the DELPHI.HDX file from the DELPHI\BIN directory.
	•	Add the .KWF file (e.g.: SAVEFRM.KWF) to the list of indexs.
	•	Save the new index file and then exit the HelpInst program.
•	Installation of the DCU, DCR, HIS and TXT files.
	•	We next must add the component to the Delphi VCL Library.
	•	Copy the DCU, DCR, HIS, and TXT files to the directory that you made for the components. (e.g.:  C:\DELPHI\COMPONEN)
	•	Load delphi and selected the Options menu Item, and then selected the Install Components… option. You should get a screen as follows.
	•	Add the directory where you have installed the components to the search path directory. All components that get installed must be in this search path.
	•	Click the add button and then the browse button to navigate to the directory where you copied the .DCU file (e.g.: C:\DELPHI\COMPONEN)
	•	Select the List Files Of Type and select Unit File *.DCU, you should then see the DCU file that you copied to the directory. Select the file and you will be returned to the Install Components dialog box.
	•	Click on the OK button and the VCL library will be re-built.
	•	You will notice on your VCL Palette bar in DELPHI that there is now a new tab called ADROCK, in side here will be an icon to represent the component you just installed.
•	Other Files.
	•	The SAVEFRM.HIS file contains a history of updates and changes made.
	•	The SAVEFRM.TXT file contains a brief description and ordering details.
Note:	We hope you have no trouble in using this component in your projects and that you like using it and other Adrock components.  We welcome feedback from you, with you we can make better upgrades and quicker fixes to any problems that you are experiencing. Please contact us at  CompuServe 100353,110 or Internet: DHMCC@IBM.NET.


SaveDefaultIniFileSettings

Applies to

TAdrockFormPosition components

Declaration

Procedure SaveDefaultIniFileSettings;

Description

This method saves the current form size and position to the INI file as a default. If the property SaveDefaultDetails is set to true then this method is automatically called when the form is created or the ReadIniFileSettingsHLP_ReadIniFileSettingsis called for the first time.

To restore the default settings call RestoreDefaultIniFileSettings


RestoreDefaultIniFileSettings

Applies to

TAdrockFormPosition components

Declaration

Procedure RestoreDefaultIniFileSettings;

Description

Calling this method will restore the default form settings, that have been saved with SaveDefaultIniFileSettings


SaveDefaultDetails

Applies to

TAdrockFormPosition components

Declaration

Property: SaveDefaultDetails : Boolean;

Description

If this property is set to true then when the ReadIniFileSettings method is called for the first time during the current session the default settings of the form are saved, these settings can be restored using the RestoreDefaultIniFileSettings method.

If this property is false then default settings are not saved, you can call the method SaveDefaultIniFileSettings to create default settings at any time. When you call the method directly though code the current view is saved.